package com.daqian.mall.service;

import com.daqian.mall.entity.BaseCategory;
import com.daqian.mall.mapper.BaseCategoryMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class CategoryService {

    @Resource
    private BaseCategoryMapper baseCategoryMapper;

    /**
     * 获取一级目录列表
     *
     * @return
     */
    public List<BaseCategory> listRoot() {
        return baseCategoryMapper.listRoot();
    }


    /**
     * 根据pid获取下级类目列表
     *
     * @param pid
     * @return
     */
    public List<BaseCategory> listSubListByParentId(Long pid) {
        return baseCategoryMapper.listSubListByParentId(pid);
    }


    /**
     * 根据类目id获取类目属性
     *
     * @param id
     * @return
     */
    public BaseCategory getAttrById(Long id) {
        return baseCategoryMapper.getAttrById(id);
    }


    /**
     * 根据类目id获取类目规格
     *
     * @param id
     * @return
     */
    public BaseCategory getSpecById(Long id) {
        return baseCategoryMapper.getSpecById(id);
    }

}


